The present invention relates to controlling processor access to resources which must be exclusively accessed in a multiprocessor environment.
Systems of multiple processors often share common resources, such as records in memory, specialized registers, indicators, etc. Such systems normally require a mechanism whereby a given processor can indicate the need to temporarily reserve or "block" a resource from use or modification by other processors. This locking insures exclusive access to that resource for the given processor.
For example, a given processor may need to make a number of individual modifications to a data structure in a memory to bring that data structure from one valid state to another. A lock can be used to indicate to other processors during modification of the data structure that the data structure should not be accessed. This mechanism requires that processors obey a policy in which the state of a lock is inspected before the associated resource is accessed. The process of inspecting a lock, and setting it to the locked state if found to be presently unlocked, must be done "atomically" i.e. without any intervening operations from other processors, and is conventionally called a "read.sub.-- modify-write" operation. This atomicity is required to insure that no more than one processor at a time "owns" a given lock.
A processor seeking exclusive use of a resource typically will issue a read command having the address of a lock indicator associated with that resource. The contents of the addressed lock indicator are put on an address/data bus to be read by the seeking processor. Simultaneously, a mechanism, typically suspension of bus usage, is invoked to temporarily suspend access to the addressed resource by all other processors.
The seeking processor inspects the lock indicator data it reads on the address/data bus to determine the locked/unlocked status of the resource of interest. If, according to the contents of the lock indicator, the resource is indicated to be locked, then the seeking processor must presently release the address/data bus and may re-examine the lock indicator at a later time. Alternatively, if, according to the contents of the lock indicator, the resource is indicated to be unlocked, then the seeking processor modifies the lock indicator contents with a write command communicated over the address/data bus to indicate that the resource is reserved for exclusive access by the seeking processor. The processor is now said to have "acquired" the lock. The seeking processor, now as the locking processor, can exclusively process or modify the data in the now locked resource as needed.
When the locking processor no longer needs exclusive access to the resource, it will issue a write command directed to the resource's associated lock indicator to clear the lock indication. This is called "relinquishing" the lock. Now the resource is available for access by other processors, or can be locked for exclusive access by another processor executing the process detailed above.